﻿using BizTalk.ESB.Extensions.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Drawing.Design;
using Microsoft.Practices.Modeling.ExtensionProvider.Metadata;
using Microsoft.Practices.Services.ItineraryDsl;
using Microsoft.Practices.Modeling.ExtensionProvider.Extension;
using Microsoft.Practices.Modeling.Common;
using Microsoft.Practices.Modeling.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.Services.Extenders;
using Microsoft.Practices.Modeling.Services.Design;
using Microsoft.Practices.Modeling.Common.Design;

namespace BizTalk.ESB.Extensions.ServiceExtenders
{
	[Serializable]
	[ObjectExtender(typeof(ItineraryService))]
	public class ServiceProxyExtender : ItineraryServiceExtenderBase, IOrchestrationItineraryServiceExtender
	{
		[Editor(typeof(BiztalkOrchestrationServiceNameEditor), typeof(UITypeEditor))]
		[TypeConverter(typeof(TypeConverter))]
		[EditorOutputProperty(BiztalkOrchestrationServiceNameEditor.ServiceId, "ServiceId")]
		public override string ServiceName { get; set; }

		public override string ServiceType
		{
			get { return "Orchestration"; }
		}

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Determines whether the itinerary will continue or stop in case of an error."),
            DisplayName("Stop On Error"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Boolean StopOnError { get; set; }

		[Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
			Description("Value of the Retries property which the target service is subscribing to."),
			DisplayName("Number of Retries"),
			ReadOnly(false),
			Browsable(true)]
		[XmlElement]
		[PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Int32 Retries { get; set; }

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Number of seconds to delay between service call attempts."),
            DisplayName("Retry Interval Seconds"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Int32 RetrySeconds { get; set; }

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Number of hours used for the Service Scope timeout."),
            DisplayName("Routing Timeout Hours"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Int32 RoutingTimeoutHours { get; set; }

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Number of minutes used for the Service Scope timeout."),
            DisplayName("Routing Timeout Minutes"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Int32 RoutingTimeoutMinutes { get; set; }

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Number of seconds used for the Service Scope timeout."),
            DisplayName("Routing Timeout Seconds"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public Int32 RoutingTimeoutSeconds { get; set; }

        [Category(ServiceProxyExtensionProvider.ExtensionProviderPropertyCategory),
            Description("Specifies which XLANGs message to use when resolving response processing details. NOTE: only valid for orchestration itinerary services."),
            DisplayName("Response Resolver Message"),
            ReadOnly(false),
            Browsable(true)]
        [XmlElement]
        [PersistInPropertyBag] 		//NOTE: This property will be persited in the service property bag
        public BreUseMsgOption ResponseResolverMessage { get; set; }

	}
}
